package com.travel.blog.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.travel.blog.entity.InfoEntity;
import com.travel.blog.service.InfoService;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.R;



/**
 * 
 *
 * @author lxw
 * @email lxw@gmail.com
 * @date 2023-10-30 21:52:24
 */
@RestController
@RequestMapping("/blog/info")
public class InfoController {
    @Autowired
    private InfoService infoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("blog:info:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = infoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{blogId}")
    //@RequiresPermissions("blog:info:info")
    public R info(@PathVariable("blogId") Integer blogId){
		InfoEntity info = infoService.getById(blogId);

        return R.ok().put("info", info);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("blog:info:save")
    public R save(@RequestBody InfoEntity info){
		infoService.save(info);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("blog:info:update")
    public R update(@RequestBody InfoEntity info){
		infoService.updateById(info);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("blog:info:delete")
    public R delete(@RequestBody Integer[] blogIds){
		infoService.removeByIds(Arrays.asList(blogIds));

        return R.ok();
    }

}
